<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt"%>

<!DOCTYPE html>
<html>
<head>
    <title>招标项目管理报价密码管理</title>
    <%@ include file="/WEB-INF/component/commonCSS.jsp"%>
</head>
<body class="skin-blue sidebar-mini fixed skin-blue-light-frame">
    <section class="content-header">
    </section>
    
    <section class="content">
        <div class=" box box-success ">
            
            <form id="form" class="form-horizontal" action="${ctx }/prodProject/setPassword.html" method="post">
                <input type="hidden" id="projId" name="projId" value="${projId}" />
                <input type="hidden" id="compId" name="compId" value="${compId}" />
                <input type="password" style="display:none" />
                <div class="box-body">
                    <c:if test="${ hasPassword }">
	                    <div class="form-group form-group-xs">
	                        <label for="recpAddr" class="col-sm-3 control-label"><span class="required">*</span>原密码：</label>
	                        <div class="col-sm-7">
	                             <input class="form-control" id="oldPassword" name="oldPassword" placeholder="请输入原密码" type="password" maxlength="18" />
	                        </div>
	                    </div>
                    </c:if>
                    
                    <div class="form-group form-group-xs">
                        <label for="recpAddr" class="col-sm-3 control-label"><span class="required">*</span>新密码：</label>
                        <div class="col-sm-7">
                             <input class="form-control" id="password" name="password" placeholder="请输入新密码" type="password" maxlength="18" />
                        </div>
                    </div>
                    
                    <div class="form-group form-group-xs">
                        <label for="recpAddr" class="col-sm-3 control-label"><span class="required">*</span>确认密码：</label>
                        <div class="col-sm-7">
                             <input class="form-control" id="passwordAffirm" placeholder="请输入确认密码" type="password" maxlength="18" />
                        </div>
                    </div>
                    
                </div>
                <div class="form-group form-group-xs">
					        <label for="newpassword" class="col-sm-2 text-right"><i class="fa fa-exclamation-circle fa-lg" style="color:#dd4b39;"></i>&nbsp;<span style="color:#dd4b39;font-weight:600">提示：</span></label>					        
						    <div class="col-sm-10 text-left" style="color:#dd4b39">
						            密码长度为6-12位且包含有大写字母、小写字母、数字和特殊字符('~!@#$%^&*()_+`\-={}:'<>?,.\/')组成
						    </div>
				         </div>
                <div class="box-footer text-center">
                   <button type="button" onclick="save();" class="btn btn-success btn-sm" >保&nbsp;存</button>
                </div>
            </form>
        </div>
    </section>
    
    <%@ include file="/WEB-INF/component/commonJS.jsp"%>
    <script type="text/javascript">

    
     function save() {
       if (!validate()) {
           return;
       }  
       $.HN.message.confirm('确定要保存吗？', '', '').on(function (e) {
          if (e) {
                   $("#form").ajaxSubmit({
                       dataType : "json",
                       timeout: 10000,
                       success : function(result) {
                           if (result.success) {
                               $.HN.message.alert("操作成功！", "消息", "success");
                               if("${defaultP}"){
                            	   setTimeout("top.mainframe.document.location = '${ctx}/prodProject/toProjectList.html'",500);
                               }else{
                            	   setTimeout("top.mainframe.document.location = '${ctx}/prodProject/toProjectListPassword.html'",500);
                               }
                           } else {
                               $.HN.message.alert(result.msg || "操作失败", "消息", "error");
                           }
                       }
                   });
              }
         });
       
   } 
   
 
 

 
 
//效验
 function validate() {
	
	var hasOld = "${hasPassword}" == "true";
	var oldPassword = $.trim($("#oldPassword").val());

	if (hasOld) {
		if (oldPassword == null || oldPassword == "") {
	         $.HN.message.alert("请输入原密码！", "提示信息", "warn");
	         return false;
	     }
	}
	var parn = /^(?=.*[A-Z])(?=.*[a-z])(?=.*\d)(?=.*[~!@#$%^&*()_+`\-={}:";'<>?,.\/]).{6,12}$/;
     var password = $.trim($("#password").val());
     if (password == null || password == "") {
         $.HN.message.alert("请输入新密码！", "提示信息", "warn");
         return false;
     } else if (!(parn.test(password))) {
    	 $.HN.message.alert("密码至少有一个大写字母、一个小写字母、数字和一个特殊字符('~!@#$%^&*()_+`\-={}:'<>?,.\/')组成", "消息", "warn");
         return false;
     } else if (password.length < 6) {
         $.HN.message.alert("密码长度为6-18位！", "提示信息", "warn");
         return false;
     }
     
     
     var passwordAffirm = $.trim($("#passwordAffirm").val());
     if (passwordAffirm == null || passwordAffirm == "") {
         $.HN.message.alert("请输入确认密码！", "提示信息", "warn");
         return false;
     } else if (passwordAffirm != password ) {
         $.HN.message.alert("确认密码与密码不一致！请重新输入确认密码", "提示信息", "warn");
         return false;
     }
     
     if (hasOld && oldPassword == password) {
    	 $.HN.message.alert("新密码不能与原密码相同！", "提示信息", "warn");
         return false;
     }
   
     return true;
 }
    
    </script>
    
</body>
</html>
